

/*
William D. Hicks, Seth C. McKee, and Daniel A. Smith
   "Contemporary Views of Liberal Democracy and the 2016 Presidential Election" in PS
*/

/*
.DO file created by William D. Hicks (hickswd@appstate.edu)

It reproduces FIGURES 1-4 in the main manuscript. 

It requires user written program: coefplot
 
Last update to this file: 5/6/2020 
This file directs the following tasks:
   (1) recodes political equality items 
   (2) labels political equality items 
   (3) estimates means from political equality items
   (4) replaces dataset with McClosky's political equality estimates 
   (5) reproduces FIGURE 1 as .PDF, .EPS, and .TIF files
       - FIGURE_1.pdf, FIGURE_1.eps, FIGURE_1.tif
   (6) reloads raw data 
   (7) recodes racial and ethnic equality items 
   (8) labels racial and ethnic equality items
   (9) estimates means from racial and ethnic equality items
   (10) replaces dataset with McClosky's racial and ethnic equality estimates 
   (11) reproduces FIGURE 2 as .PDF, .EPS, and .TIF files
       - FIGURE_2.pdf, FIGURE_2.eps, FIGURE_2.tif
   (12) reloads raw data 
   (13) recodes rules of the game items 
   (14) labels rules of the game items
   (15) estimates means from rules of the game items
   (16) replaces dataset with McClosky's rules of the game estimates 
   (17) reproduces FIGURE 3 as .PDF, .EPS, and .TIF files
       - FIGURE_3.pdf, FIGURE_3.eps, FIGURE_3.tif
   (13) reloads raw data 
   (13) recodes free speech and procedural rights items 
   (14) labels free speech and procedural rights items
   (15) estimates means from free speech and procedural rights items
   (16) replaces dataset with McClosky's free speech and procedural rights estimates 
   (17) reproduces FIGURE 4 as .PDF, .EPS, and .TIF files
       - FIGURE_4.pdf, FIGURE_4.eps, FIGURE_4.tif
*/

/*
                 YOU NEED TO FIRST IMPORT THE .DTA DATASET
                 THIS REQUIRES THAT YOU WRITE YOUR OWN PATH
		     YOU WILL HAVE TO RELOAD THE DATASET SEVERAL TIMES
*/

use ~[FILE PATH]/CCES16_HMS_REPLICATION.dta, clear 

/*
            OUTPUT (ALL TABLES & GRAPHS) SAVED TO ~DIRECTORY
    -you also need to set the appropriate location for a directory file - 
*/

cd [MAKE YOUR DIRECTORY HERE]

/*

	                            FOLLOWING CODE PRODUCES FIGURE 1 
	   
IT INCLUDES ITEMS FROM MCCLOSKY'S TABLE 5.1 POLITICAL EQUALITY SUB-TABLE
	
QUESTIONS ARE HMS403A-HMS403E
*/



use ~[FILE PATH]/CCES16_HMS_REPLICATION.dta, clear 



foreach var of varlist HMS403A - HMS403E ///
{
		gen `var'_rev= (`var'*-1)+2
}

foreach var of varlist HMS403A_rev - HMS403E_rev ///
{
		recode `var'(-6=.)
}

sum HMS403A_rev - HMS403E_rev	


lab var HMS403A_rev "...people don't know what's best for them" 
lab var HMS403B_rev "Few people know what's in their best interest..." 
lab var HMS403C_rev "Issues are beyond the understanding of most voters" 
lab var HMS403D_rev "...people lack sense to pick leaders wisely" 
lab var HMS403E_rev "...necessary to have few strong, able people in power" 


mean HMS403A_rev-HMS403E_rev
estimates store CCES3


clear
set obs 1484

gen HMS403A_rev = 1
gen HMS403B_rev = 1
gen HMS403C_rev = 1
gen HMS403D_rev = 1
gen HMS403E_rev = 1

lab var HMS403A_rev "...people don't know what's best for them" 
lab var HMS403B_rev "Few people know what's in their best interest..." 
lab var HMS403C_rev "Issues are beyond the understanding of most voters" 
lab var HMS403D_rev "...people lack sense to pick leaders wisely" 
lab var HMS403E_rev "...necessary to have few strong, able people in power" 

/* FULL/LONGER VARIABLE LABELS
lab var HMS403A_rev "Trouble with democracy is people don't know what's best for them." 
lab var HMS403B_rev "Few people know what's in their own best interest in the long run." 
lab var HMS403C_rev "Issues and arguments are beyond the understanding of most voters." 
lab var HMS403D_rev "Most people don't have enough sense to pick leaders wisely" 
lab var HMS403E_rev "Always be necessary to have few strong, able people running everything" 
*/

di 1484*.580
replace HMS403A_rev = 0 if _n>861
di 1484*.611
replace HMS403B_rev = 0 if _n>907
di 1484*.623
replace HMS403C_rev = 0 if _n>925
di 1484*.478
replace HMS403D_rev = 0 if _n>710
di 1484*.562
replace HMS403E_rev = 0 if _n>834

/*TRUE VALUES FROM MCCLOSKY'S TABLE 
replace HMS403A_rev = .580
replace HMS403B_rev = .611
replace HMS403C_rev = .623
replace HMS403D_rev = .478
replace HMS403E_rev = .562
*/

mean HMS403A_rev-HMS403E_rev
estimates store MCC3

coefplot (CCES3, label(CCES 2016) msymbol(S) mcolor(gs10) ciopts(lcolor(gs10)) offset(0.05)) ///
         (MCC3, label(McClosky 1950s) msymbol(D) mcolor(gs5) ciopts(lcolor(gs5)) pstyle(p4) offset(-0.05)), ///  
         cismooth  ///
         scheme(s2mono) ///
		 order(HMS403C_rev HMS403E_rev HMS403A_rev HMS403B_rev HMS403D_rev) ///
		 xlabel(.2(0.1).9, labsize(small)) ///
		 xtitle("Proportion Who Agree", size(small)) ///
		 coeflabels(, labsize(vsmall)) ///
		 legend( size(small)) ///
		 graphregion(fcolor(white) icolor(white) lcolor(white) ///
		 margin(50 2 2 2)) 
gr export FIGURE_1.pdf, replace
gr export FIGURE_1.eps, replace
gr export FIGURE_1.tif, replace


/*

	                            FOLLOWING CODE PRODUCES FIGURE 2 
	   
IT INCLUDES ITEMS FROM MCCLOSKY'S TABLE 5.2 SOCIAL & ETHNIC EQUALITY SUB-TABLE
	
QUESTIONS ARE HMS411A-HMS411E
*/

			
use ~[FILE PATH]/CCES16_HMS_REPLICATION.dta, clear 

foreach var of varlist HMS411A - HMS411E ///
{
		gen `var'_rev= (`var'*-1)+2
}

foreach var of varlist HMS411A_rev - HMS411E_rev ///
{
		recode `var'(-6=.)
}

sum HMS411A_rev - HMS411E_rev

lab var HMS411A_rev "Some people are better, despite what we teach"
lab var HMS411B_rev "Some breeds of people are better than others" 
lab var HMS411C_rev "Certain races won't mix with Americans"
lab var HMS411D_rev "All races are certainly not equal" 
lab var HMS411E_rev "Minorities take over neightborhood if allowed..." 

mean HMS411A_rev-HMS411E_rev
estimates store CCES4


clear
set obs 1484

gen HMS411A_rev= 1
gen HMS411B_rev= 1
gen HMS411C_rev= 1
gen HMS411D_rev= 1
gen HMS411E_rev= 1

lab var HMS411A_rev "Some people are better, despite what we teach"
lab var HMS411B_rev "Some breeds of people are better than others" 
lab var HMS411C_rev "Certain races won't mix with Americans"
lab var HMS411D_rev "All races are certainly not equal" 
lab var HMS411E_rev "Minorities take over neightborhood if allowed..."

/* FULL/LONGER VARIABLE LABELS
lab var HMS411A_rev "Teach children all men are equal, but we know some are better than others"
lab var HMS411B_rev "Some breeds of people are just naturally better than others" 
lab var HMS411C_rev "Certain races in the world won't mix with Americans"
lab var HMS411D_rev "All races are certainly not equal" 
lab var HMS411E_rev "Trouble with letting minorities into neightborhood is they make it their own" 
*/ 

di 1484*.583
replace HMS411A_rev = 0 if _n>865
di 1484*.463
replace HMS411B_rev = 0 if _n>687
di 1484*.504
replace HMS411C_rev = 0 if _n>748
di 1484*.490
replace HMS411D_rev = 0 if _n>727
di 1484*.577
replace HMS411E_rev = 0 if _n>857


/* TRUE VALUES
replace HMS411A_rev = .583
replace HMS411B_rev = .463
replace HMS411C_rev = .504
replace HMS411D_rev = .490
replace HMS411E_rev = .577
*/

mean HMS411A_rev-HMS411E_rev
estimates store MCC4

coefplot (CCES4, label(CCES 2016) msymbol(S) mcolor(gs10) ciopts(lcolor(gs10)) offset(0.05)) ///
         (MCC4, label(McClosky 1950s) msymbol(D) mcolor(gs5) ciopts(lcolor(gs5)) pstyle(p4) offset(-0.05)), ///  
         cismooth  ///
         scheme(s2mono) ///
		 order(HMS411B_rev HMS411D_rev HMS411E_rev HMS411C_rev HMS411A_rev) ///
		 xlabel(.1(0.1).7, labsize(small)) ///
		 xtitle("Proportion Who Agree", size(small)) ///
		 coeflabels(, labsize(vsmall)) ///
		 legend( size(small)) ///
		 graphregion(fcolor(white) icolor(white) lcolor(white) ///
		 margin(50 2 2 2))
gr export FIGURE_2.pdf, replace
gr export FIGURE_2.eps, replace
gr export FIGURE_2.tif, replace
/*

	                          FOLLOWING CODE PRODUCES FIGURE 3
	   
IT INCLUDED ITEMS FROM MCCLOSKY'S TABLE 1, Rules of the Game (minus a few)
	   
IT ALSO REVERSES CODES SO POSITIVE REPRESENTS AGREEMENT/SUPPORT

Questions are HMS313A-HMS313I
	   
*/

use ~[FILE PATH]/CCES16_HMS_REPLICATION.dta, clear 

replace HMS311b = . if HMS311b>100



foreach var of varlist HMS313A - HMS313I ///
{
		gen `var'_rev= (`var'*-1)+2
}

foreach var of varlist HMS313A_rev - HMS313I_rev ///
{
		recode `var' (-6=.)
}
sum HMS313A_rev-HMS313I_rev


lab var HMS313A_rev "...people should take law into their own hands"
label var HMS313B_rev "...innocent people suffer [improving the world]"
label var HMS313C_rev "Politician's methods don't matter..."
label var HMS313D_rev "...purpose justifies unfairness or brutality" 
label var HMS313E_rev "Politicians need to cut corners"
label var HMS313F_rev "Everyone should be able to vote"
label var HMS313G_rev "...mankind often requires cruelty & ruthlessness" 
label var HMS313H_rev "It's alright to get around the law..." 
label var HMS313I_rev "...use force to save true American way of life"

mean HMS313A_rev-HMS313I_rev
estimates store CCES1


clear
set obs 1484
/* MCCLOSKY DATASET 1 (sample size 1484 with fewer than 1% don't knows) */


gen HMS313A_rev = 1
gen HMS313B_rev = 1
gen HMS313C_rev = 1
gen HMS313D_rev = 1
gen HMS313E_rev = 1
gen HMS313F_rev = 1
gen HMS313G_rev = 1
gen HMS313H_rev = 1
gen HMS313I_rev = 1

lab var HMS313A_rev "...people should take law into their own hands"
label var HMS313B_rev "...innocent people suffer [improving the world]"
label var HMS313C_rev "Politician's methods don't matter..."
label var HMS313D_rev "...purpose justifies unfairness or brutality" 
label var HMS313E_rev "Politicians need to cut corners"
label var HMS313F_rev "Everyone should be able to vote"
label var HMS313G_rev "...mankind often requires cruelty & ruthlessness" 
label var HMS313H_rev "It's alright to get around the law..." 
label var HMS313I_rev "...use force to save true American way of life"

/* FULL/LONGER VARIABLE LABELS
lab var HMS313A_rev "Sometimes people should take law into their own hands"
label var HMS313B_rev "Making the world better means innocent people will suffer"
label var HMS313C_rev "Politician's methods don't matter if he/she gets the job done"
label var HMS313D_rev "Great purpose justifies unfairness or brutality" 
label var HMS313E_rev "Politicians need to cut corners"
label var HMS313F_rev "People should be allowed to vote if even they can't do so intelligently"
label var HMS313G_rev "Benefit of mankind often requires cruelty & ruthlessness" 
label var HMS313H_rev "It's alright to get around the law if you don't break it" 
label var HMS313I_rev "May need to use force to save true American way of life"
*/


/* TRUE VALUES FROM MCCLOSKY */
/*
gen HMS313A_rev = .269
gen HMS313B_rev = .416 
gen HMS313C_rev = .424
gen HMS313D_rev = .328
gen HMS313E_rev = .432
gen HMS313F_rev = .476
gen HMS313G_rev = .313
gen HMS313H_rev = .302
gen HMS313I_rev = .346
*/
/* ESTIMATES */


di 1484*.269
replace HMS313A_rev = 0 if _n>400
di 1484*.416
replace HMS313B_rev = 0 if _n>618
di 1484*.424
replace HMS313C_rev = 0 if _n>629
di 1484*.328
replace HMS313D_rev = 0 if _n>487
di 1484*.432
replace HMS313E_rev = 0 if _n>641
di 1484*.476
replace HMS313F_rev = 0 if _n>707
di 1484*.313
replace HMS313G_rev = 0 if _n>465
di 1484*.302
replace HMS313H_rev = 0 if _n>449
di 1484*.346
replace HMS313I_rev = 0 if _n>514

mean HMS313A_rev-HMS313I_rev
estimates store MCC1

/* following command requires installing user written program coefplot*/

coefplot (CCES1, label(CCES 2016) msymbol(S) mcolor(gs10) ciopts(lcolor(gs10)) offset(0.05)) ///
         (MCC1, label(McClosky 1950s) msymbol(D) mcolor(gs5) ciopts(lcolor(gs5)) pstyle(p4) offset(-0.05)), ///  
         cismooth  ///
		 order(HMS313G_rev HMS313B_rev HMS313E_rev HMS313D_rev HMS313C_rev HMS313H_rev) ///
         scheme(s2mono) ///
		 xlabel(.1(0.1)0.6, labsize(small)) ///
		 xtitle("Proportion Who Agree", size(small)) ///
		 coeflabels(, labsize(vsmall)) ///
		 legend( size(small)) ///
		 graphregion(fcolor(white) icolor(white) lcolor(white) ///
		 margin(50 2 2 2)) 
gr export FIGURE_3.pdf, replace
gr export FIGURE_3.eps, replace
gr export FIGURE_3.tif, replace


/*

	                       FOLLOWING CODE PRODUCES FIGURE 4 
	   
IT INCLUDES ITEMS FROM MCCLOSKY'S TABLE 3 FREE SPEECH and PROCEDURAL RIGHTS
	
QUESTIONS ARE HMS406A-HMS406G

*/


use ~[FILE PATH]/CCES16_HMS_REPLICATION.dta, clear 

foreach var of varlist HMS406A - HMS406G ///
{
		gen `var'_rev= (`var'*-1)+2
}

foreach var of varlist HMS406A_rev - HMS406G_rev ///
{
		recode `var'(-6=.)
}
sum HMS406A_rev-HMS406G_rev	

lab var HMS406A_rev "Shouldn't teach foreign ideas in school" 
lab var HMS406B_rev "Censor books that contain wrong political views..." 
lab var HMS406C_rev "...may have to force people to testify against themselves..." 
lab var HMS406D_rev "...person has the right to face & question accusers"
lab var HMS406E_rev "Set free persons convicted by illegal evidence" 
lab var HMS406F_rev "Don't consider people who hide behind the law" 
lab var HMS406G_rev "...can't afford to depend on slow courts & laws" 

mean HMS406A_rev-HMS406G_rev
estimates store CCES2

clear
set obs 1484

gen HMS406A_rev=1
gen HMS406B_rev=1
gen HMS406C_rev=1
gen HMS406D_rev=1
gen HMS406E_rev=1
gen HMS406F_rev=1
gen HMS406G_rev=1

/* TRUE VALUES FROM MCCLOSKY
replace HMS406A_rev = .567
replace HMS406B_rev = .503
replace HMS406C_rev = .363
replace HMS406D_rev = .881
replace HMS406E_rev = .661
replace HMS406F_rev = .757
replace HMS406G_rev = .255
*/

di 1484*.567
replace HMS406A_rev = 0 if _n>842
di 1484*.503
replace HMS406B_rev = 0 if _n>747
di 1484*.363
replace HMS406C_rev = 0 if _n>539
di 1484*.881
replace HMS406D_rev = 0 if _n>1308
di 1484*.661
replace HMS406E_rev = 0 if _n>981
di 1484*.757
replace HMS406F_rev = 0 if _n>1124
di 1484*.255
replace HMS406G_rev = 0 if _n>379

mean HMS406A_rev-HMS406G_rev

lab var HMS406A_rev "Shouldn't teach foreign ideas in school" 
lab var HMS406B_rev "Censor books that contain wrong political views..." 
lab var HMS406C_rev "...may have to force people to testify against themselves..." 
lab var HMS406D_rev "...person has the right to face & question accusers"
lab var HMS406E_rev "Set free persons convicted by illegal evidence" 
lab var HMS406F_rev "Don't consider people who hide behind the law" 
lab var HMS406G_rev "...can't afford to depend on slow courts & laws" 

/* FULL/LONGER VARIABLE LABELS
lab var HMS406A_rev "Freedom doesn't allow anyone to teach foreign ideas in school" 
lab var HMS406B_rev "Book that contains wrong political views shouldn't be published" 
lab var HMS406C_rev "We may have to force people to testify against themselves in times of danger" 
lab var HMS406D_rev "A person should never be convicted without the right to face & question accusers"
lab var HMS406E_rev "A person should be set free if convicted of crime by illegal evidence" 
lab var HMS406F_rev "A person who hides behind the law when questioned doesn't deserve consideration" 
lab var HMS406G_rev "With enemies like [Communists/ISIS], can't afford to depend on slow courts & laws" 
*/

mean HMS406A_rev-HMS406G_rev
estimates store MCC2

coefplot (CCES2, label(CCES 2016) msymbol(S) mcolor(gs10) ciopts(lcolor(gs10)) offset(0.05)) ///
         (MCC2, label(McClosky 1950s) msymbol(D) mcolor(gs5) ciopts(lcolor(gs5)) pstyle(p4) offset(-0.05)), ///  
         cismooth  ///
         scheme(s2mono) ///
		 order(HMS406C_rev HMS406B_rev HMS406A_rev HMS406F_rev HMS406D_rev HMS406E_rev) ///
		 xlabel(.2(0.1).9, labsize(small)) ///
		 xtitle("Proportion Who Agree", size(small)) ///
		 coeflabels(, labsize(vsmall)) ///
		 legend( size(small)) ///
		 graphregion(fcolor(white) icolor(white) lcolor(white) ///
		 margin(55 2 2 2)) 
gr export FIGURE_4.pdf, replace
gr export FIGURE_4.eps, replace
gr export FIGURE_4.tif, replace



